]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Instantiate EndSessionDialog
authorCharles Wong <ymqiuyu@gmail.com>
Sat, 28 Oct 2023 07:34:36 +0000 (15:34 +0800)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 30 Nov 2023 17:44:58 +0000 (18:44 +0100)
Using an exported `init()` function to create the object is an odd
pattern, and not having the object referenced anywhere makes it harder
to access for debugging or extensions.

Just export the `EndSessionDialog` class and instantiate it like we
do for other objects.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2997>
(cherry picked from commit 6ff08fd9bd86a6b38f210759181203279321c43b)

js/ui/endSessionDialog.js
js/ui/main.js

index a704cb3e70fae23623545944763af092b68500f9..56a5aec05ae1200652f3220882848a40aef0ba53 100644 (file)
@@ -223,14 +223,7 @@ function _setCheckBoxLabel(checkBox, text) {
     }
 }
 
-export function init() {
-    // This always returns the same singleton object
-    // By instantiating it initially, we register the
-    // bus object, etc.
-    new EndSessionDialog();
-}
-
-const EndSessionDialog = GObject.registerClass(
+export const EndSessionDialog = GObject.registerClass(
 class EndSessionDialog extends ModalDialog.ModalDialog {
     _init() {
         super._init({
index 9e14bc141dab892f2b16e8215c68c07eb13cd111..ad6d3d61137ee475600584fe761827dc0045d24f 100644 (file)
@@ -90,6 +90,7 @@ export let kbdA11yDialog = null;
 export let inputMethod = null;
 export let introspectService = null;
 export let locatePointer = null;
+export let endSessionDialog = null;
 
 let _startDate;
 let _defaultCssStylesheet = null;
@@ -275,7 +276,7 @@ async function _initializeUI() {
 
     // Provide the bus object for gnome-session to
     // initiate logouts.
-    EndSessionDialog.init();
+    endSessionDialog = new EndSessionDialog.EndSessionDialog();
 
     // We're ready for the session manager to move to the next phase
     GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {